<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			var msgs=[]
			function fun1(){
				document.getElementById("username").value=""
				document.getElementById("word").value=""
				document.getElementById("words").value=""
				msgs=[]
				msgs.length=0
			}
			function fun2(){
			var name=document.getElementById("username").value
			var word=document.getElementById("word").value
			var msg=`[${name}]说：${word}`
			msgs.unshift(msg)
			if(msgs.length>10){
				msgs.pop()
			}
			document.getElementById("words").value=msgs.join("\n")
			}
			
		</script>
	</head>
	<body>
		姓名：<input type="text"  id="username" /><br>
		留言：<textarea rows="3" cols="40" id="word"></textarea><br>
		<button type="button" onclick="fun1()">重置</button>
		<button type="button" onclick="fun2()">留言</button>
		<hr>
		<textarea rows="10" cols="60" id="words"></textarea>
	</body>
</html>
